/*
 * @Author: your name
 * @Date: 2021-03-30 10:48:00
 * @LastEditTime: 2021-04-02 09:18:42
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \xcc-front\src\common\message\index.js
 */
// import { cookieStorage } from 'common/storage'
import { Message } from 'element-ui'
let messageInstance = null
const resetMessage = options => {
  if (messageInstance) {
    messageInstance.close()
  }
  messageInstance = Message(options)
}
;['error', 'success', 'info', 'warning'].forEach(type => {
  resetMessage[type] = options => {
    if (typeof options === 'string') {
      options = {
        message: options,
        showClose: true,
        duration: 1500
      }
    }
    options.type = type
    return resetMessage(options)
  }
})
resetMessage.close = Message.close
resetMessage.closeAll = Message.closeAll
export const message = resetMessage
